<template>
  <div id="testlist">
    <el-dialog title="人员信息详情" :visible.sync="personDetailVisible" width="80%" top="20px" :close-on-click-modal="false" :close-on-press-escape="false">
      <personInfo :personId='personId'></personInfo>
    </el-dialog>
    <el-breadcrumb separator=">">
      <el-breadcrumb-item :to="{ path: '/' }">系统首页</el-breadcrumb-item>
      <el-breadcrumb-item :to="{ path: '/shiyongqi' }">试用期满</el-breadcrumb-item>
    </el-breadcrumb>
    <section class="wboxd" style="margin-top:10px">
      <!--列表-->
      <h1>{{title}}</h1>
      <el-table ref="multipleTable" :data="personList" highlight-current-row v-loading="listLoading" style="width: 100%;" :height="tableHeight" border @selection-change="handleSelectionChange" >
        <el-table-column type="index" label=" " width="50" fixed align="center" class-name="tableth">
        </el-table-column>
        <el-table-column prop="unitname" label="单位" show-overflow-tooltip>
        </el-table-column>
        <el-table-column label="姓名" width="120">
          <template slot-scope="scope">
            <el-button size="small" @click="persondetail(scope.row.idnumber)" type="text" icon="el-icon-search"><span style="color:#0058AC;font-weight:bolder">{{scope.row.personname}}</span></el-button>
          </template>
        </el-table-column>
        <el-table-column prop="zhiwuname" label="现任职务" width="400" show-overflow-tooltip>
        </el-table-column>
        <el-table-column prop="renzhishijian" label="任职时间" width="160" show-overflow-tooltip>
          <template slot-scope="scope">
            {{text2month(scope.row.renzhishijian)}}
          </template>
        </el-table-column>
        <el-table-column prop="renzhiwenhao" label="任职文号" width="250" show-overflow-tooltip>
        </el-table-column>
        <el-table-column prop="renzhiwenhao" label="状态" width="100" align="center" show-overflow-tooltip>
          <template slot-scope="scope">
            <el-tag v-if="scope.row.ifshiyongqiman" type="success" effect="dark" style="cursor:pointer" title="点击将此信息设为不提示" @click="setState(scope.row,false)">提示</el-tag>
            <el-tag v-else type="info" effect="dark" style="cursor:pointer" title="点击将此信息设为提示" @click="setState(scope.row,true)">不提示</el-tag>
          </template>
        </el-table-column>
      </el-table>
    </section>
  </div>
</template>

<script>
import personInfo from '@/person/Detail.vue'
export default {
  components: {
    personInfo
  },
  data () {
    return {
      title: '',
      submitLoading: false,
      ids: [],
      personDetailVisible: false,
      personId: 0,
      personList: [],
      total: 0,
      pageNum: 1,
      pageSize: 20,
      listLoading: false,
      totalnum: 0,
      Isace: true,
      Sortkey: '',
      changeSizeFlag: false,
      tableHeight: 100
    }
  },
  methods: {
    setState (data, state) {
      console.log(data)
      const stateText = state ? '确定将此信息设为提示？' : '确定将此信息设为不提示？'
      this.$confirm(stateText, '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.$http
          .post('/binfo/shiyongqimantishi', {id: data.id, idnumber: data.idnumber, tishi: state})
          .then(response => {
            if (response.data === true) {
              this.$message({
                message: '操作成功',
                type: 'success'
              })
              this.getList()
            } else {
              console.log('操作失败:' + response.data.message)
              this.$message({
                message: '操作失败:' + response.data.message,
                type: 'error'
              })
            }
          })
          .catch(error => {
            console.log(error)
          })
      }).catch(() => {
      })
    },
    handleSelectionChange (val) {
      this.ids = val.map(item => item.id)
    },
    persondetail (id) {
      this.personDetailVisible = true
      this.personId = id
    },
    getList () {
      this.listLoading = true
      this.$http
        .get(`/binfo/shiyongqiman`)
        .then(response => {
          this.listLoading = false
          this.personList = response.data.list
          this.title = response.data.msg
        })
        .catch(error => {
          this.$message({
            message: '获取失败:' + error,
            type: 'error'
          })
        })
    },
    tableresize (obj) {
      var clientHeight = 0
      if (document.body.clientHeight && document.documentElement.clientHeight) {
        clientHeight = (document.body.clientHeight < document.documentElement.clientHeight) ? document.body.clientHeight : document.documentElement.clientHeight
      } else {
        clientHeight = (document.body.clientHeight > document.documentElement.clientHeight) ? document.body.clientHeight : document.documentElement.clientHeight
      }
      obj.$nextTick(function () {
        obj.tableHeight = clientHeight - 192
      })
    }
  },
  mounted () {
    this.getList()
    this.tableresize(this)
    let _this = this
    window.onresize = function windowResize () {
      // 通过捕获系统的onresize事件触发我们需要执行的事件
      _this.tableresize(_this)
    }
  }
}
</script>
<style>
  .wboxd .el-table th{
    font-weight: normal;
    background-image: linear-gradient(to bottom , #f8f8f8, #efefef);
  }
  .wboxd .el-table td, .el-table th{
    padding:0;
    font-size:var(--size14) !important;
    line-height: 20px;
    font-family: '宋体'
  }
  .tableth{
    background-image: linear-gradient(to bottom , #f8f8f8, #efefef);
    height:33px;
  }
  #testlist .wboxs{
    height:45px;
    padding-top:10px;
  }
  .el-table--border th, .el-table--border td {
    border-right: 1px solid #95B8E7;
  }
  .el-table th.is-leaf, .el-table td {
    border-bottom: 1px solid #95B8E7;
  }

</style>
<style scoped>
  h1{
    font-size:var(--size16) !important;
    font-weight: bolder;
    height: 30px;
    border-bottom: 1px solid #95B8E7;
    font-family: '宋体';
    line-height: 30px;
    color: #000;
    padding-left:10px;
    background-image: linear-gradient(to bottom , #EEF4FF, #E0ECFF);
    margin:0;
  }
  .el-pagination{
    float: left;
    padding:7px 10px;
  }
  .wboxs{
    padding:5px 15px;
    width: calc(100% - 30px);
    background: #fff;
    border: 1px solid #95B8E7;
    margin:0 10px;
    overflow: hidden;
  }
  .wboxd{
    padding:0;
    width: calc(100% - 0px);
    background: #fff;
    border: 1px solid #95B8E7;
    margin:0 10px;
    overflow: hidden;
  }
</style>
